#include <stdio.h>

int main(void)
{	 	 	      
    char t[80], ch;
    int i, len;
    double x;

    i = 0;
    printf("请输入十六进制字符串：");
    while ((ch = getchar()) != '\n')
    {	 	 	      
        if ((ch >= '0' && ch <= '9')
                || (ch >= 'a' && ch <= 'f')
                || (ch >= 'A' && ch <= 'F'))
        {	 	 	      
            t[i] = ch;
            i++;
        }
    }
    len = i;
    t[i] = '\0';
    printf("十六进制串%s的值=十进制", t);

    x = 0.0;
    for (i = 0; i < len; i++)
    {	 	 	      
        if (t[i] >= '0' && t[i] <= '9')
        {	 	 	      
            x = x * 16 + (t[i] - '0');
        }
        else if (t[i] >= 'a' && t[i] <= 'f')
        {	 	 	      
            x = x * 16 + (t[i] - 'a' + 10);
        }
        else if (t[i] >= 'A' && t[i] <= 'F')
        {	 	 	      
            x = x * 16 + (t[i] - 'A' + 10);
        }
    }

    printf("%.0f\n", x);

    return 0;
}